import time

from selenium import webdriver
from selenium.webdriver.common.by import By


class Keyword:

    def __init__(self):
        self.driver=webdriver.Chrome()


    def openBrower(self,br=''):
        self.driver.maximize_window()
        self.driver.implicitly_wait(10)

    def visiturl(self,url=''):
        self.driver.get(url)


    #查找元素
    def __find_element(self,locator=''):
        ele=self.driver.find_element(By.XPATH,locator)
        return ele

    #输入操作
    def input(self,locator='',value=''):
        ele=self.__find_element(locator)
        ele.send_keys(value)

    #点击操作
    def click(self,locator=''):
        ele=self.__find_element(locator)
        ele.click()

    # 等待操作
    def sleep(self,sleeptime=''):
        num=float(sleeptime)
        time.sleep(num)

    #切换Iframe
    def swich_iframe(self,locator=''):
        ele=self.__find_element(locator)
        self.driver.switch_to.frame(ele)



